home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Table / Sources / Proxy.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  6.6 KB  |  233 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Proxy.cpp
  4. //    Release Version:    $ ODF 2 $ 
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "Table.hpp"
  11.  
  12. // ----- TablePart Includes -----
  13.  
  14. #ifndef PROXY_H
  15. #include "Proxy.h"
  16. #endif
  17.  
  18. #ifndef FRAME_H
  19. #include "Frame.h"
  20. #endif
  21.  
  22. #ifndef CONTENT_H
  23. #include "Content.h"
  24. #endif
  25.  
  26. // ----- Framework Includes -----
  27.  
  28. #ifndef FWFRMING_H
  29. #include "FWFrming.h"
  30. #endif
  31.  
  32. #ifndef FWITERS_H
  33. #include "FWIters.h"
  34. #endif
  35.  
  36. #ifndef FWUTIL_H
  37. #include "FWUtil.h"
  38. #endif
  39.  
  40. #ifndef FWFCTCLP_H
  41. #include "FWFctClp.h"
  42. #endif
  43.  
  44. #ifndef FWPXYFRM_H
  45. #include "FWPxyFrm.h"
  46. #endif
  47.  
  48. #ifndef FWTCOLL_H
  49. #include "FWTColl.h"
  50. #endif
  51.  
  52. // ----- OS Includes -----
  53.  
  54. #ifndef FWODGEOM_H
  55. #include "FWODGeom.h"
  56. #endif
  57.  
  58. #ifndef FWFXMATH_H
  59. #include "FWFxMath.h"
  60. #endif
  61.  
  62. //========================================================================================
  63. // Runtime Info
  64. //========================================================================================
  65.  
  66. #ifdef FW_BUILD_MAC
  67. #pragma segment odfTable
  68. #endif
  69.  
  70. //========================================================================================
  71. // class CShapeCollection
  72. //========================================================================================
  73.  
  74. FW_DEFINE_AUTO(CTableProxyCollection)
  75.  
  76. //========================================================================================
  77. // class CShapeCollectionIterator
  78. //========================================================================================
  79.  
  80. FW_DEFINE_AUTO(CTableProxyCollectionIterator)
  81.  
  82. //========================================================================================
  83. //    class CTableProxy
  84. //========================================================================================
  85.  
  86. //----------------------------------------------------------------------------------------
  87. //    CTableProxy::CTableProxy
  88. //----------------------------------------------------------------------------------------
  89.  
  90. CTableProxy::CTableProxy(Environment* ev, CTablePart* tablePart, CTablePartContent* tableContent) :
  91.     FW_MProxy(ev, tablePart),
  92.     fTablePart(tablePart),
  93.     fTableContent(tableContent),
  94.     fCell(0, 0),
  95.     fLinkSpecID(0)
  96. {
  97. }
  98.  
  99. //----------------------------------------------------------------------------------------
  100. //    CTableProxy::~CTableProxy
  101. //----------------------------------------------------------------------------------------
  102.  
  103. CTableProxy::~CTableProxy()
  104. {
  105. }
  106.  
  107. //----------------------------------------------------------------------------------------
  108. //    CTableProxy::UsedShapeChanged
  109. //----------------------------------------------------------------------------------------
  110.  
  111. void CTableProxy::UsedShapeChanged(Environment *ev,
  112.                                    FW_CEmbeddingFrame* embeddingFrame,
  113.                                    ODFrame* odEmbeddedFrame)
  114. {
  115. FW_UNUSED(odEmbeddedFrame);
  116.  
  117.     FW_CRect cellRect;
  118.     fTableContent->FindRect(fCell, cellRect);
  119.     FW_CAcquiredODShape aqInvalidShape = ::FW_NewODShape(ev, cellRect);
  120.  
  121. /*
  122.     FW_CAcquiredODShape aqUsedShape(FW_CopyAndRelease(ev, odEmbeddedFrame->AcquireUsedShape(ev, NULL)));
  123.         
  124.     // ----- For the Table part, all embedded facets have the same externalTransform
  125.     ODFacet *facet;
  126.     {
  127.         FW_CODFrameFacetIterator ite(ev, odEmbeddedFrame);
  128.         facet = ite.First(ev);
  129.     }
  130.     if (facet == NULL)
  131.         return;
  132.     
  133.     {
  134.         FW_CAcquiredODTransform aqExternalTransform(facet->AcquireExternalTransform(ev, NULL));
  135.         aqUsedShape->Transform(ev, aqExternalTransform);
  136.         aqInvalidShape->Subtract(ev, aqUsedShape);
  137.     }
  138. */
  139.  
  140.     // ----- Invalidate
  141.     embeddingFrame->Invalidate(ev, aqInvalidShape);
  142.     
  143.     // ----- Recalculate the clip
  144.     FW_CFacetClipper facetClipper;
  145.     facetClipper.Clip(ev, fTablePart->GetTablePresentation(ev), NULL);
  146. }
  147.  
  148. //----------------------------------------------------------------------------------------
  149. //    CTableProxy::FrameShapeRequested
  150. //----------------------------------------------------------------------------------------
  151.  
  152. ODShape* CTableProxy::FrameShapeRequested(Environment* ev, 
  153.                                         FW_CEmbeddingFrame* embeddingFrame, 
  154.                                         ODFrame* odEmbeddedFrame, 
  155.                                         ODShape* askedFrameShape)
  156. {
  157. FW_UNUSED(embeddingFrame);
  158. FW_UNUSED(askedFrameShape);
  159. FW_UNUSED(odEmbeddedFrame);
  160.  
  161.     FW_CRect cellRect;
  162.     fTableContent->FindRect(fCell, cellRect);
  163.  
  164.     cellRect.Place(FW_kZeroPoint);
  165.     ODShape* cellShape = ::FW_NewODShape(ev, cellRect);
  166.     
  167.     return cellShape;
  168. }
  169.  
  170. //----------------------------------------------------------------------------------------
  171. //    CTableProxy::MoveEmbeddedFrames
  172. //----------------------------------------------------------------------------------------
  173.  
  174. void CTableProxy::MoveEmbeddedFrames(Environment* ev, const CCell& destCell)
  175. {
  176.     FW_CRect rect;
  177.     fTableContent->FindRect(destCell, rect);
  178.     ChangeFrameShapes(ev, rect.Width(), rect.Height());
  179.     ChangeExternalTransforms(ev, rect.left, rect.top);
  180.     
  181.     //     [HLX] because I can't create facets with a NULL clip (bug in OpenDoc???) I have to 
  182.     //    Clip my embedded facets everytime
  183.     FW_CFacetClipper facetClipper;
  184.     facetClipper.Clip(ev, fTablePart->GetTablePresentation(ev), NULL);
  185. }
  186.  
  187. //----------------------------------------------------------------------------------------
  188. //    CTableProxy::AcquireHiliteShape
  189. //----------------------------------------------------------------------------------------
  190.  
  191. ODShape* CTableProxy::AcquireHiliteShape(Environment* ev, const CCell& cell, FW_CEmbeddingFrame* frame)
  192. {
  193.     FW_CRect rect;
  194.     fTableContent->FindRect(cell, rect);
  195.  
  196.     FW_CAcquiredODFrame embeddedFrame = this->AcquireEmbeddedFrame(ev, frame);
  197.     FW_CAcquiredODShape usedShape = FW_CopyAndRelease(ev, embeddedFrame->AcquireUsedShape(ev, NULL));
  198.     FW_CAcquiredODTransform transform = ::FW_NewODTransform(ev, rect.TopLeft());
  199.     usedShape->Transform(ev, transform);
  200.     ODShape* hiliteShape = ::FW_NewODShape(ev, rect);
  201.     hiliteShape->Subtract(ev, usedShape);
  202.     return hiliteShape;
  203. }
  204.  
  205. //----------------------------------------------------------------------------------------
  206. //    CTableProxy::CreateFacets
  207. //----------------------------------------------------------------------------------------
  208.  
  209. short CTableProxy::CreateFacets(Environment* ev,
  210.                                 FW_CEmbeddingFrame* embeddingFrame,
  211.                                 ODFacet* embeddingFacet,
  212.                                 ODFrame* embeddedFrame,
  213.                                 ODShape* proposedClipShape)
  214. {
  215. FW_UNUSED(embeddingFrame);
  216.     FW_CRect rect;
  217.     fTableContent->FindRect(fCell, rect);
  218.     
  219.     FW_CAcquiredODTransform aqExternalTransform = ::FW_NewODTransform(ev, rect.TopLeft());
  220.  
  221.     CreateFacet(ev,
  222.                 embeddingFacet,
  223.                 embeddedFrame,
  224.                 proposedClipShape,
  225.                 aqExternalTransform,
  226.                 NULL,                    // Canvas
  227.                 NULL,                    // biasCanvas
  228.                 NULL,                    // siblingFacet
  229.                 kODFrameInFront);
  230.     return 1;
  231. }
  232.  
  233.